package frist50;

import org.junit.jupiter.api.Test;

public class T0007 {
    public int reverse(int x) {
        StringBuffer strb=new StringBuffer();
        strb.append(x);
        boolean b=true;
        if(strb.charAt(0)=='-'){
            b=false;
            strb.deleteCharAt(0);
        }
        strb.reverse();
        long l=Long.parseLong(strb.toString());
        if(!b)l=-l;
        if(l>Integer.MAX_VALUE||l<Integer.MIN_VALUE)return 0;
        return (int)l;
    }
    @Test
    public void test() {

        reverse(123);

    }
}
